#pragma once

#include "precomp.h"
#include "Physics.h"
#include "Gravity.h"
#include "ForceExplosion.h"

//game logic for connect four
class GameLogic
{
protected:
	int timer;
	float fps;
	
	enum GameState {RUN, FIRST_XP, PAUSE};
	GameState gameState;
	bool debugOn;

	CL_Font_System smallFont;
	CL_Font_System largeFont;

	Physics* physics;
	std::list<Particle> particles;
	std::list<LimitedPlane> planes;
	//Plane floorPlane;
	std::list<ForceGenerator*> forceGenerators;

	Gravity gravity;
	ForceExplosion* explosion;

	Particle* anchor;
	Particle* remoteParticle;
	LinearSpring* spring;

public:
	int width, height; //width and height of the screen
	GameLogic(void);
	~GameLogic(void);

	void init(CL_GraphicContext& gc);
	void reset(float x, float y);
	
	//void userInput(CL_InputDevice keyboard, CL_InputDevice mouse);
	void mouseDown(const CL_InputEvent &event, const CL_InputState &state);
	void keyDown(const CL_InputEvent &event, const CL_InputState &state);
	void keyUp(const CL_InputEvent &event, const CL_InputState &state);

	//update calls userinput
	//void update(int delta, CL_InputDevice keyboard, CL_InputDevice mouse);
	void update(int delta);
	void drawPlane(CL_GraphicContext& gc, Plane* plane);
	void drawLimitedPlane(CL_GraphicContext& gc, LimitedPlane* plane);
	void drawSpring(CL_GraphicContext& gc, LinearSpring* spring);
	void draw(CL_GraphicContext& gc);
	void explode();

	CL_ColorHSVf velocityToHSV(Vector3f v);
};

